package org.lgiavedoni.android.franq;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.lgiavedoni.android.franq.core.Context;
import org.lgiavedoni.android.franq.core.context.DefaultContext;
import org.lgiavedoni.android.franq.core.service.ServiceManager;
import org.lgiavedoni.android.franq.service.communication.CommunicationService;
import org.lgiavedoni.android.franq.service.config.ConfigService;
import org.lgiavedoni.android.franq.service.log.Logger;
import org.lgiavedoni.android.franq.util.implementation.ImplementationUtil;
import org.lgiavedoni.android.franq.util.resource.ResourceUtil;
import org.lgiavedoni.android.franq.util.thread.ThreadUtil;

import com.google.inject.Guice;

public class FrankMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		start();
	}

	public static void start() {
		Context.setInjector(Guice.createInjector(new DefaultContext()));

		// Set the config
		if (ResourceUtil.inst.getResource("config") != null) {
			ImplementationUtil.addImplementationSource(ResourceUtil.inst.getResource("/config"));
			try {
				ConfigService.inst.addPropertiesSource((new FileInputStream(ResourceUtil.inst.getResource("/config/default_config.properties"))));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		ServiceManager.inst.startServices();

		Logger.inst.info("Frank is wake-up");

		ThreadUtil.sleep(3000);
		// hi msg
		CommunicationService.inst.sendDefaultTextMessage("I am at your service sir");
	}

}
